package com.kefu.chat.vo;

import java.util.ArrayList;
import java.util.List;

import javax.validation.constraints.NotEmpty;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.google.common.collect.Lists;
import com.kefu.chat.model.*;
import com.kefu.common.vo.AbstractInsertVo;
import com.kefu.robot.model.RobotDocComment;
import com.kefu.robot.model.RobotDocNode;
import com.kefu.robot.vo.RobotDocVo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

public class ChatUserParam {

    @Data
    public static class UserInitP {
        @ApiModelProperty(value = "用户id，页面生产和缓存")
        private String userId;
        @ApiModelProperty(value = "渠道id")
        private String channelId;
        @ApiModelProperty(value = "对接id")
        private String pid;
        @ApiModelProperty(value = "用户姓名")
        private String userName;
        @ApiModelProperty(value = "邮箱")
        private String email;
        @ApiModelProperty(value = "手机号")
        private String phone;
        @ApiModelProperty(value = "自定义字段，json格式")
        private String params;
        @ApiModelProperty(value = "客户等级，0是普通客户，1是VIP")
        private Integer vipLevel;
        @ApiModelProperty(value = "多语言，zh,en,vi,th")
        private String locale;
        @ApiModelProperty(value = "sdk来源，1安卓，2苹果")
        private Integer sdkFrom;
        @ApiModelProperty(value = "sdk版本，例如1.0.0")
        private String sdkVersion;
        @ApiModelProperty(value = "referer")
        private String referer;
    }
    @Data
    public static class UserInitR {
    	@ApiModelProperty(value = "userId")
        private String userId;
        @ApiModelProperty(value = "用户状态： 0离线， 1机器人， 2在线， 3排队")
        private int status;
        @ApiModelProperty(value = "轮询消息id")
        private String pollId;
        @ApiModelProperty(value = "sessionId")
        private String sessionId;
        @ApiModelProperty(value = "adminNick")
        private String adminNick;
        @ApiModelProperty(value = "服务器时间")
        private long serverTime = System.currentTimeMillis();
        @ApiModelProperty(value = "是否提交过询前表单：0否，1是")
        private int userFormMode;
    }
    
    @Data
    public static class UserChangeP {
    	@ApiModelProperty(value = "用户id，页面生产和缓存")
    	private String userId;
    	@ApiModelProperty(value = "对接id")
    	private String pid;
    	@ApiModelProperty(value = "用户姓名")
    	private String userName;
    	@ApiModelProperty(value = "邮箱")
    	private String email;
    	@ApiModelProperty(value = "手机号")
    	private String phone;
    	@ApiModelProperty(value = "自定义字段，json格式")
    	private String params;
    	@ApiModelProperty(value = "客户等级，0是普通客户，1是VIP")
    	private Integer vipLevel;
    	@ApiModelProperty(value="轮询ID")
    	private String pollId; //轮询消息id
    }

    @Data
    public static class UserRobotAskP {
        private String userId;
        @ApiModelProperty(value = "问题")
        private String question;
        @ApiModelProperty(value = "点选问题的时候，需要传递docId")
        private String docId;
        @ApiModelProperty(value = "点击推荐问题传1，点击机器人输入提示传2")
        private int click;
        @ApiModelProperty(value = "多轮问题，节点ID",notes = "在调用接口的时候需要始终传递该数据")
        private String nodeId;
        @ApiModelProperty(value = "多轮问题，点击子项itemId")
        private String itemId;
        @ApiModelProperty(value = "多轮问题，点击子项itemId 绑定代码")
        private String itemBindCode;
        @ApiModelProperty(value = "多轮问题，点击子项itemId 绑定值，默认是 question 如果该值不为空，则绑定该值")
        private String itemBindValue;
        @ApiModelProperty(value = "机器人标识")
        private int robotNo=1;
        @ApiModelProperty(value = "清理html标签，0不清理，1清理")
        private int cleanHtmlTag = 0;
    }
    @Data
    public static class UserRobotAskR {
        @ApiModelProperty(value = "消息id")
        private String msgId;
        @ApiModelProperty(value = "status 0会话已结束，1正常，2已是在线状态，-1命中转人工")
        private int status = 1;
        @ApiModelProperty(value = "answer")
        private String answer;
        @ApiModelProperty(value = "回答类型，0未知回答，1直接回答，2引导回答，-1自定义寒暄，-2基本寒暄，-3互联网寒暄 -4Ai大模型")
        private int answerType=0;
        @ApiModelProperty(value = "命中的标准问题")
        private String question;
        @ApiModelProperty(value = "docId")
        private String docId;
        @ApiModelProperty(value = "score")
        private float score;
        @ApiModelProperty(value = "模式：0单轮问题，1多轮问题")
        private Integer docPattern = 0;
        @ApiModelProperty(value = "机器人建议")
        private List<RobotDocVo> suggestList = new ArrayList<>();
        @ApiModelProperty(value = "多轮问题节点")
        private RobotDocNode docNode;
        @ApiModelProperty(value = "html内容地址")
        private String htmlUrl;
        @ApiModelProperty(value = "3富文本，4文件，5音频，6视频，7商品卡片，8订单卡片,9工单卡片")
        private Integer msgType;
    }
    @Data
    public static class UserRobotSuggest extends RobotDocVo {
    	@ApiModelProperty
        private float score;
    }


    @Data
    public static class UserRobotTipsP {
    	@ApiModelProperty
        private String userId;
        @ApiModelProperty(value = "问题")
        private String question;
        @ApiModelProperty(value = "机器人标识")
        private int robotNo=1;
    }



    @Data
    public static class UserConnectP {
        @ApiModelProperty(required = true)
        private String userId;
        @ApiModelProperty
        private String groupId;
        @ApiModelProperty
        private String adminId;
        @ApiModelProperty(hidden=true)
        private boolean queue;
    }
    @Data
    public static class UserConnectR {
        @ApiModelProperty(value = "0会话已经结束，1无客服在线， 2转人工成功， 3转人工排队，4 黑名单，5 非工作时间")
        private int status;
        @ApiModelProperty
        private String adminNick;
        @ApiModelProperty
        private String adminFace;
        @ApiModelProperty(value = "排队位置")
        private long waitIndex;
        @ApiModelProperty(value = "客服id")
        private String adminId;
        List<UserConnectP> actions=Lists.newArrayList();
    }


    @Data
    public static class UserSendMsgP {
        private String userId;
        @ApiModelProperty(value = "消息类型：1.文字，2图片，3富文本，4文件，5音频，6视频，7商品卡片，8订单卡片")
        private int msgType=1;
        @ApiModelProperty(value="消息内容")
        private String msgContent;
        @ApiModelProperty(value="文件名字")
        private String fileName;
        @ApiModelProperty(value="音频时长，秒")
        private Integer audioDuration;
    }

    @Data
    public static class UserSysMsgP {
        @ApiModelProperty(value="用户id")
        private String userId;
        @ApiModelProperty(value="消息内容")
        private String msgContent;
        @ApiModelProperty(value = "展示位置：0.两端都展示，1.展示在坐席端，2.展示在客户端")
        private int clientType;
    }

    @Data
    public static class UserSendMsgR {
        private String status;
        @ApiModelProperty(value = "敏感词")
        private List<String> sensitiveWords;
    }

    @Data
    public static class UserGetEventMsgP {
    	@ApiModelProperty
        private String userId;
        @ApiModelProperty(value = "轮询id，初始化接口返回")
        private String pollId;
    }
    @Data
    public static class UserGetEventMsgR {
        @ApiModelProperty(value = "event_type事件类型：" +
                "1200-会话建立（排队中进入或者排队中被邀请），" +
                "1201-收到新消息，1202-会话结束（outType结束方式：1会话超时，2客服结束，3新窗口打开）" +
                "1203-被客服邀请满意度评价，1204-客服正在输入")
        private List msgList;
        @ApiModelProperty(value = "排队位置")
        private long waitIndex;
        @ApiModelProperty(value = "用户状态： 0离线， 1机器人， 2在线， 3排队")
        private int status;
        private String adminNick;
    }

    @Data
    public static class UserP {
    	@ApiModelProperty
        private String userId;
    	private String pid;
    }

    @Data
    public static class UserTypingP {
        @ApiModelProperty
        private String userId;
        @ApiModelProperty
        private String msgContent;
    }

    @Data
    public static class UserGetSessionMsgP {
    	@ApiModelProperty
        private String userId;
    	@ApiModelProperty
        private String sessionId;
        @ApiModelProperty(value = "清理html标签，0不清理，1清理")
        private int cleanHtmlTag = 0;
    }
    @Data
    public static class UserGetSessionMsgR {
    	@ApiModelProperty
        private String id;
    	@ApiModelProperty
        private String sessionId;
        @ApiModelProperty(value = "发送者id")
        private String sender;
        @ApiModelProperty(value = "发送者名字")
        private String senderName;
        @ApiModelProperty(value = "发送者类型：1用户，2客服，3机器人，4系统")
        private Integer senderType;
        @ApiModelProperty
        private Integer msgType;
        @ApiModelProperty
        private String msgContent;
        @ApiModelProperty
        private Long msgTime;
        @ApiModelProperty(value = "机器人建议")
        private String robotSuggest;
        @ApiModelProperty(value = "文件名字")
        private String fileName;
        @ApiModelProperty(value = "模式：0单轮问题，1多轮问题")
        private Integer docPattern;
        @ApiModelProperty(value = "多轮词条节点")
        private String docNode;
        @ApiModelProperty(value = "敏感词内容")
        private String sensitiveWords;
        @ApiModelProperty(value = "敏感词标志 0=无，1=有")
        private Integer sensitiveFlag;
        @ApiModelProperty(value = "消息撤回标志 0=无，1=有")
        private Integer recallFlag;
        @ApiModelProperty(value = "词条id")
        private String docId;
        @ApiModelProperty(value = "html内容地址")
        private String htmlUrl;
        @ApiModelProperty(value="音频时长，秒")
        private Integer audioDuration;
        @ApiModelProperty(value = "消息已读未读 0=未读，1=已读")
        private Integer readFlag;
        @ApiModelProperty(value = "展示位置：0.两端都展示，1.展示在坐席端，2.展示在客户端")
        private Integer clientType;
    }

    @Data
    public static class UserGetHistoryMsgP {
    	@ApiModelProperty
        private String userId;
        @ApiModelProperty(value = "根据最大时间往前翻页")
        private long maxTime;
        @ApiModelProperty(value = "每页大小")
        private int pageSize=15;
        @ApiModelProperty(value = "清理html标签，0不清理，1清理")
        private int cleanHtmlTag = 0;


    }

    @Data
    public static class UserChannelP {
    	@ApiModelProperty
        private String userId;
    	@ApiModelProperty
        private String channelId;
    }

    @Data
    @ApiModel(value = "敏感词校验")
    public static class CheckSensitiveP {
        @ApiModelProperty(value = "内容")
        private String msgContent;
    }

    @Data
    @ApiModel(value = "在线留言")
    public static class ChatLeaveMsgP {
        @NotEmpty
        @ApiModelProperty(value = "渠道")
        private String channelId;

        @ApiModelProperty
        private String leaveMsgWoType;

        @ApiModelProperty
        private String userId;

        @ApiModelProperty(value = "联系姓名")
        private String customerName;

        @ApiModelProperty(value = "电话号码")
        private String customerPhone;

        @ApiModelProperty(value = "邮箱地址")
        private String customerEmail;

        @ApiModelProperty(value = "留言内容")
        private String msgContent;
    }

    @Data
    public static class SubmitUserFormP {
        @ApiModelProperty(value = "用户id")
        private String userId;
        @ApiModelProperty(value = "用户姓名")
        private String userName;
        @ApiModelProperty(value = "邮箱")
        private String email;
        @ApiModelProperty(value = "手机号")
        private String phone;
    }

    @Data
    @ApiModel("语音转文字")
    public static class TransferVideoR {
        private String result;
        private Long startTime;
        private Long endTime;
    }

    @Data
    public static class GetRobotDocP {
        @ApiModelProperty(value = "用户id")
        private String userId;
        @ApiModelProperty(value = "词条id")
        private String docId;
    }

    @Data
    public static class GetRobotDocR {
        @ApiModelProperty(value = "标准问题")
        private String docQuestion;
        @ApiModelProperty(value = "词条答案，富文本格式")
        private String docAnswer;
    }

    @Data
    public static class UserVideoInvitation{
        @ApiModelProperty(value = "客户id")
        private String userId;
        @ApiModelProperty(value = "会话id")
        private String sessionId;
        @ApiModelProperty(value = "语音通话类型,1语音 2视频 ")
        private Integer videoType;


    }

    @Data
    public static class UserCommentDoc extends AbstractInsertVo<RobotDocComment> {
        @ApiModelProperty(value = "词条id")
        private String docId;
        @ApiModelProperty(value = "消息id")
        private String msgId;
        @ApiModelProperty(name = "userId", value = "用户id")
        private String userId;
        @ApiModelProperty(name = "sessionId", value = "会话id")
        private String sessionId;
        @ApiModelProperty(name = "robotNo", value = "机器人")
        private Integer robotNo;
        @ApiModelProperty(hidden = true)
        private String tenantId;
        @ApiModelProperty(name = "isUseful", value = "点赞状态 0=踩，1=赞")
        private Integer isUseful;

        @Override
        public RobotDocComment convert() {
            RobotDocComment info = BeanUtil.toBean(this, RobotDocComment.class);
            info.setCreateTime(DateUtil.current());
            return info;
        }
    }
}
